package com.kuangstudy.collection.list;

import java.util.LinkedList;
import java.util.ListIterator;

/**
 * ClassName: Demo6
 * date: 2021/07/12 18:10:49
 *
 * @author zlk
 */
public class Demo6 {
    public static void main(String[] args) {
        LinkedList linkedList = new LinkedList<>();
        Student s1 = new Student("kk1", 10);
        Student s2 = new Student("kk2", 11);
        Student s3 = new Student("kk3", 12);
        linkedList.add(s1);
        linkedList.add(s2);
        linkedList.add(s3);
        linkedList.add(s3);
//        System.out.println(linkedList.toString());
//        linkedList.remove(s1);
//        System.out.println(linkedList.toString());
//        linkedList.clear();
//        System.out.println(linkedList.size());
        /*迭代器遍历*/
//        Iterator iterator = linkedList.iterator();
//        while (iterator.hasNext()) {
//            System.out.println(iterator.next());
//        }
        ListIterator listIterator = linkedList.listIterator();
        while (listIterator.hasNext()) {
            System.out.println(listIterator.next());
        }
    }
}
